﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IFTRUE.EIMS.Web.Ashx
{
    /// <summary>
    /// EnterpriseInfo 的摘要说明
    /// </summary>
    public class EnterpriseInfo : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            //安全验证
            string strMsg = "";
            if (!AshxCheck.Check(context, ref strMsg))
            {
                context.Response.Write(SysMsg.GetCommonMsg(strMsg));
                return;
            }
            if (context.Request["type"] == "save")
            {
                string strClass = context.Request["class"];
                if (string.IsNullOrEmpty(strClass))
                {
                    context.Response.Write(SysMsg.Error);
                    return;
                }
                BLL.EnterpriseInfo enterpriseInfoBLL = new BLL.EnterpriseInfo();
                Model.EnterpriseInfo enterpriseInfoModel = enterpriseInfoBLL.Get(MySession.CurrentUser.Id);
                if (enterpriseInfoModel == null)
                {
                    context.Response.Write(SysMsg.GetCommonMsg("该帐号没有关联企业信息，请联系管理员"));
                    return;
                }
                switch (strClass)
                {
                    case "qyjbqk":
                        enterpriseInfoModel.Tbr = context.Request["Tbr"];
                        enterpriseInfoModel.Lxdh = context.Request["Lxdh"];
                        enterpriseInfoModel.Yx = context.Request["Yx"];
                        enterpriseInfoModel.Qymc = context.Request["Qymc"];
                        enterpriseInfoModel.Zczb = Helper.TypeChange.str2realtype<double>(context.Request["Zczb"], 0);
                        enterpriseInfoModel.Zzhjzqk = context.Request["Zzhjzqk"];
                        enterpriseInfoModel.Sfwgxjsqy = string.IsNullOrEmpty(context.Request["Sfwgxjsqy"]) ? false : true;
                        enterpriseInfoModel.Sfwlxsqy = string.IsNullOrEmpty(context.Request["Sfwlxsqy"]) ? false : true;
                        break;
                    case "qyryqktj":
                        enterpriseInfoModel.Yyyg_zrs = Helper.TypeChange.str2realtype<int>(context.Request["Yyyg_zrs"], 0);
                        enterpriseInfoModel.Yyyg_dzys = Helper.TypeChange.str2realtype<int>(context.Request["Yyyg_dzys"], 0);
                        enterpriseInfoModel.Yyyg_ss = Helper.TypeChange.str2realtype<int>(context.Request["Yyyg_ss"], 0);
                        enterpriseInfoModel.Yyyg_bs = Helper.TypeChange.str2realtype<int>(context.Request["Yyyg_bs"], 0);
                        enterpriseInfoModel.Yyyg_lxry = Helper.TypeChange.str2realtype<int>(context.Request["Yyyg_lxry"], 0);
                        enterpriseInfoModel.Byxz_zrs = Helper.TypeChange.str2realtype<int>(context.Request["Byxz_zrs"], 0);
                        enterpriseInfoModel.Byxz_dzys = Helper.TypeChange.str2realtype<int>(context.Request["Byxz_dzys"], 0);
                        enterpriseInfoModel.Byxz_ss = Helper.TypeChange.str2realtype<int>(context.Request["Byxz_ss"], 0);
                        enterpriseInfoModel.Byxz_bs = Helper.TypeChange.str2realtype<int>(context.Request["Byxz_bs"], 0);
                        enterpriseInfoModel.Byxz_lxry = Helper.TypeChange.str2realtype<int>(context.Request["Byxz_lxry"], 0); break;
                    case "zsqktj":
                        enterpriseInfoModel.Ysqzsqk = context.Request["Ysqzsqk"];
                        enterpriseInfoModel.Xsqzsqk = context.Request["Xsqzsqk"];
                        break;
                    case "qyscxkzjcpzczqk":
                        enterpriseInfoModel.Yhcpzczsl = Helper.TypeChange.str2realtype<int>(context.Request["Yhcpzczsl"], 0);
                        enterpriseInfoModel.Byxsqcpzczsl = Helper.TypeChange.str2realtype<int>(context.Request["Byxsqcpzczsl"], 0);
                        enterpriseInfoModel.Byxhdcpzczsl = Helper.TypeChange.str2realtype<int>(context.Request["Byxhdcpzczsl"], 0);
                        enterpriseInfoModel.Sfyhscxkz = string.IsNullOrEmpty(context.Request["Sfyhscxkz"]) ? false : true;
                        enterpriseInfoModel.Scxkzbgqk = context.Request["Scxkzbgqk"];
                        enterpriseInfoModel.Yhcpzczzsbh = context.Request["Yhcpzczzsbh"];
                        break;
                    case "qyzscqqktj":
                        enterpriseInfoModel.Yyzscq_sbqk_fmzl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_sbqk_fmzl"], 0);
                        enterpriseInfoModel.Yyzscq_sbqk_syxxzl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_sbqk_syxxzl"], 0);
                        enterpriseInfoModel.Yyzscq_sbqk_wgzl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_sbqk_wgzl"], 0);
                        enterpriseInfoModel.Yyzscq_sbqk_rjzzq = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_sbqk_rjzzq"], 0);
                        enterpriseInfoModel.Yyzscq_sbqk_pct = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_sbqk_pct"], 0);
                        enterpriseInfoModel.Yyzscq_hpqk_fmzl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_hpqk_fmzl"], 0);
                        enterpriseInfoModel.Yyzscq_hpqk_syxxzl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_hpqk_syxxzl"], 0);
                        enterpriseInfoModel.Yyzscq_hpqk_wgzl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_hpqk_wgzl"], 0);
                        enterpriseInfoModel.Yyzscq_hpqk_rjzzq = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_hpqk_rjzzq"], 0);
                        enterpriseInfoModel.Yyzscq_hpqk_pct = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_hpqk_pct"], 0);
                        enterpriseInfoModel.Yyzscq_gmgwzlsl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_gmgwzlsl"], 0);
                        enterpriseInfoModel.Yyzscq_jshtjysl = Helper.TypeChange.str2realtype<int>(context.Request["Yyzscq_jshtjysl"], 0);
                        enterpriseInfoModel.Yyzscq_jshtjye = Helper.TypeChange.str2realtype<double>(context.Request["Yyzscq_jshtjye"], 0);
                        enterpriseInfoModel.Byxzzscq_sbqk_fmzl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_sbqk_fmzl"], 0);
                        enterpriseInfoModel.Byxzzscq_sbqk_syxxzl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_sbqk_syxxzl"], 0);
                        enterpriseInfoModel.Byxzzscq_sbqk_wgzl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_sbqk_wgzl"], 0);
                        enterpriseInfoModel.Byxzzscq_sbqk_rjzzq = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_sbqk_rjzzq"], 0);
                        enterpriseInfoModel.Byxzzscq_sbqk_pct = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_sbqk_pct"], 0);
                        enterpriseInfoModel.Byxzzscq_hpqk_fmzl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_hpqk_fmzl"], 0);
                        enterpriseInfoModel.Byxzzscq_hpqk_syxxzl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_hpqk_syxxzl"], 0);
                        enterpriseInfoModel.Byxzzscq_hpqk_wgzl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_hpqk_wgzl"], 0);
                        enterpriseInfoModel.Byxzzscq_hpqk_rjzzq = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_hpqk_rjzzq"], 0);
                        enterpriseInfoModel.Byxzzscq_hpqk_pct = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_hpqk_pct"], 0);
                        enterpriseInfoModel.Byxzzscq_gmgwzlsl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_gmgwzlsl"], 0);
                        enterpriseInfoModel.Byxzzscq_jshtjysl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzzscq_jshtjysl"], 0);
                        enterpriseInfoModel.Byxzzscq_jshtjye = Helper.TypeChange.str2realtype<double>(context.Request["Byxzzscq_jshtjye"], 0);
                        break;
                    case "qyqjyskjxmqk":
                        enterpriseInfoModel.Ywcxmqk_qj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Ywcxmqk_qj_sl"], 0);
                        enterpriseInfoModel.Ywcxmqk_qj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Ywcxmqk_qj_zzje"], 0);
                        enterpriseInfoModel.Zyxmqk_qj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Zyxmqk_qj_sl"], 0);
                        enterpriseInfoModel.Zyxmqk_qj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Zyxmqk_qj_zzje"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_qj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzsqxmqk_qj_sl"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_qj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzsqxmqk_qj_zzje"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_qj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzhpxmqk_qj_sl"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_qj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzhpxmqk_qj_zzje"], 0);
                        enterpriseInfoModel.Ywcxmqk_shij_sl = Helper.TypeChange.str2realtype<int>(context.Request["Ywcxmqk_shij_sl"], 0);
                        enterpriseInfoModel.Ywcxmqk_shij_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Ywcxmqk_shij_zzje"], 0);
                        enterpriseInfoModel.Zyxmqk_shij_sl = Helper.TypeChange.str2realtype<int>(context.Request["Zyxmqk_shij_sl"], 0);
                        enterpriseInfoModel.Zyxmqk_shij_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Zyxmqk_shij_zzje"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_shij_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzsqxmqk_shij_sl"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_shij_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzsqxmqk_shij_zzje"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_shij_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzhpxmqk_shij_sl"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_shij_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzhpxmqk_shij_zzje"], 0);
                        enterpriseInfoModel.Ywcxmqk_shengj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Ywcxmqk_shengj_sl"], 0);
                        enterpriseInfoModel.Ywcxmqk_shengj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Ywcxmqk_shengj_zzje"], 0);
                        enterpriseInfoModel.Zyxmqk_shengj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Zyxmqk_shengj_sl"], 0);
                        enterpriseInfoModel.Zyxmqk_shengj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Zyxmqk_shengj_zzje"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_shengj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzsqxmqk_shengj_sl"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_shengj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzsqxmqk_shengj_zzje"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_shengj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzhpxmqk_shengj_sl"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_shengj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzhpxmqk_shengj_zzje"], 0);
                        enterpriseInfoModel.Ywcxmqk_gjj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Ywcxmqk_gjj_sl"], 0);
                        enterpriseInfoModel.Ywcxmqk_gjj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Ywcxmqk_gjj_zzje"], 0);
                        enterpriseInfoModel.Zyxmqk_gjj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Zyxmqk_gjj_sl"], 0);
                        enterpriseInfoModel.Zyxmqk_gjj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Zyxmqk_gjj_zzje"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_gjj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzsqxmqk_gjj_sl"], 0);
                        enterpriseInfoModel.Byxzsqxmqk_gjj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzsqxmqk_gjj_zzje"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_gjj_sl = Helper.TypeChange.str2realtype<int>(context.Request["Byxzhpxmqk_gjj_sl"], 0);
                        enterpriseInfoModel.Byxzhpxmqk_gjj_zzje = Helper.TypeChange.str2realtype<double>(context.Request["Byxzhpxmqk_gjj_zzje"], 0);
                        enterpriseInfoModel.Shxxjtlbjmc = context.Request["Shxxjtlbjmc"];
                        break;
                    case "qyjdtj":
                        enterpriseInfoModel.Zxjdqkhb = context.Request["Zxjdqkhb"];
                        break;
                    case "qyjjgk":
                        enterpriseInfoModel.Qyndzsr = Helper.TypeChange.str2realtype<double>(context.Request["Qyndzsr"], 0);
                        enterpriseInfoModel.Qybyxzsr = Helper.TypeChange.str2realtype<double>(context.Request["Qybyxzsr"], 0);
                        enterpriseInfoModel.Qyndjlr = Helper.TypeChange.str2realtype<double>(context.Request["Qyndjlr"], 0);
                        enterpriseInfoModel.Qybyxzjlr = Helper.TypeChange.str2realtype<double>(context.Request["Qybyxzjlr"], 0);
                        enterpriseInfoModel.Qyndrdtr = Helper.TypeChange.str2realtype<double>(context.Request["Qyndrdtr"], 0);
                        enterpriseInfoModel.Qybyzxrdtr = Helper.TypeChange.str2realtype<double>(context.Request["Qybyzxrdtr"], 0);
                        enterpriseInfoModel.Qyckch = Helper.TypeChange.str2realtype<double>(context.Request["Qyckch"], 0);
                        enterpriseInfoModel.Qysjsjsf = Helper.TypeChange.str2realtype<double>(context.Request["Qysjsjsf"], 0);
                        break;
                    case "qyxstj":
                        enterpriseInfoModel.Bndmqywcxs = Helper.TypeChange.str2realtype<double>(context.Request["Bndmqywcxs"], 0);
                        enterpriseInfoModel.Bndyjsxxs = Helper.TypeChange.str2realtype<double>(context.Request["Bndyjsxxs"], 0);
                        enterpriseInfoModel.Qyzjwyczjxsyy = context.Request["Qyzjwyczjxsyy"];
                        break;
                    case "qyxqjjy":
                        enterpriseInfoModel.Zpxq = context.Request["Zpxq"];
                        enterpriseInfoModel.Pxxq = context.Request["Pxxq"];
                        enterpriseInfoModel.Qtxqjjy = context.Request["Qtxqjjy"];
                        break;
                }
                bool bl = enterpriseInfoBLL.Update(enterpriseInfoModel, strClass);
                if (bl)
                    context.Response.Write(SysMsg.GetSuccessMsg("EnterpriseInfo", "closeCurrent"));
                else
                    context.Response.Write(SysMsg.Fail);
                return;
            }
            if (context.Request["type"] == "export")
            { 

            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}